<template>
  <div class="radar">
    <!-- 为 ECharts 准备一个定义了宽高的 DOM -->
    <div id="main" style="width: 600px; height: 400px" />
  </div>
</template>
<script>
import * as echarts from 'echarts/core'
import { TitleComponent, LegendComponent } from 'echarts/components'
import { RadarChart } from 'echarts/charts'
import { CanvasRenderer } from 'echarts/renderers'
export default {
  name: 'Radar',
  mounted() {
    echarts.use([TitleComponent, LegendComponent, RadarChart, CanvasRenderer])

    var chartDom = document.getElementById('main')
    var myChart = echarts.init(chartDom)
    var option

    option = {
      title: {
        text: '基础雷达图'
      },
      legend: {
        data: ['平均水平', '个人价值']
      },
      radar: {
        // shape: 'circle',
        indicator: [
          { name: '工作效率', max: 100 },
          { name: '考勤', max: 100 },
          { name: '积极性', max: 100 },
          { name: '帮助同事', max: 100 },
          { name: '自主学习', max: 100 },
          { name: '正确率', max: 100 }
        ]
      },
      series: [
        {
          name: '平均水平 vs 个人价值',
          type: 'radar',
          data: [
            {
              value: [80, 80, 80, 80, 80, 80],
              name: '平均水平'
            },
            {
              value: [100, 100, 100, 100, 100, 100],
              name: '个人价值'
            }
          ]
        }
      ]
    }

    option && myChart.setOption(option)
  }
}
</script>
